﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using SIPO.Library.DataAccess.Report;
using SIPO.Library.DomainObject.Transaction;
using SIPO.Library.DataAccess.Transaction;
using SIPO.Web.Support;


namespace SIPO.Web.lists.Transaction
{
    public partial class monitoringPenagihan : BasePage
    {
        
        protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
                string debtorId = Request.Params["debtorId"] == null ? string.Empty : Request.Params["debtorId"].ToString();

                string param = string.Empty;
                recDemandRepo recDemandDal = new recDemandRepo(ConfigurationManager.ConnectionStrings["SIPOConn"].ConnectionString);
                List<recDemand> recDemands = recDemandDal.GetListDebtorOnRecDemand();

                ddlDebitur.Items.Clear();
                if (recDemands.Count > 0)
                {
                    recDemands.ForEach(delegate(recDemand demand)
                    {
                        ddlDebitur.Items.Add(new ListItem(demand.recDebtor.DebtorCode + '-' + demand.DebtorName, demand.DebtorID.ToString()));
                    });
                }
                ddlDebitur.Items.Insert(0, new ListItem("-- pilih debitur --",string.Empty));

                if (!debtorId.Equals(string.Empty))
                {
                    ddlDebitur.Items.FindByValue(debtorId).Selected = true;
                }
            }
        }
    }
}